#include <iostream>
#include <list>
#include <deque>
#include <vector>

using std::cout;
using std::endl;
using namespace std;

template <typename Container>
void display(const Container &con){
    for(auto &elem : con){
        cout << elem << " ";
    }
    cout << endl;
}

void test_deque(){
    cout << "===== test_deque =====" << endl;

    deque <int> number = {1, 2, 3, 4, 5, 6, 7, 8};
    deque<int>::iterator it = number.begin();
    ++it;
    ++it;
    display(number);
    cout << "*it = " << *it << endl;
    cout << endl;
    
    number.insert(it, 11);
    display(number);
    cout << "*it = " << *it << endl;
    cout << endl;

    number.insert(it, 5, 22);
    display(number);
    cout << "*it = " << *it << endl;
    cout << endl;

    vector<int> vec = {33, 333, 3333, 33333, 33333};
    number.insert(it, vec.begin(), vec.end());
    display(number);
    cout << "*it = " << *it << endl;
    cout << endl;

    number.insert(it, {44, 444, 4444, 44444});
    display(number);
    cout << "*it = " << *it << endl;
    cout << endl;

    cout << "===== test_deque =====" << endl << endl;
}

void test_list(){
    cout << "===== test_list =====" << endl;

    list <int> number = {1, 2, 3, 4, 5, 6, 7, 8};
    list<int>::iterator it = number.begin();
    ++it;
    ++it;
    display(number);
    cout << "*it = " << *it << endl;
    cout << endl;
    
    number.insert(it, 11);
    display(number);
    cout << "*it = " << *it << endl;
    cout << endl;

    number.insert(it, 5, 22);
    display(number);
    cout << "*it = " << *it << endl;
    cout << endl;

    vector<int> vec = {33, 333, 3333, 33333, 33333};
    number.insert(it, vec.begin(), vec.end());
    display(number);
    cout << "*it = " << *it << endl;
    cout << endl;

    number.insert(it, {44, 444, 4444, 44444});
    display(number);
    cout << "*it = " << *it << endl;
    cout << endl;

    cout << "===== test_list =====" << endl << endl;
}

void test_vector(){
    cout << "===== test_vector =====" << endl;

    vector <int> number = {1, 2, 3, 4, 5, 6, 7, 8};
    vector<int>::iterator it = number.begin();
    ++it;
    ++it;
    display(number);
    cout << "*it = " << *it << endl;
    cout << endl;
    
    it = number.begin();
    ++it;
    ++it;
    number.insert(it, 11);
    display(number);
    cout << "*it = " << *it << endl;
    cout << endl;

    it = number.begin();
    ++it;
    ++it;
    number.insert(it, 5, 22);
    display(number);
    cout << "*it = " << *it << endl;
    cout << endl;

    it = number.begin();
    ++it;
    ++it;
    vector<int> vec = {33, 333, 3333, 33333, 33333};
    number.insert(it, vec.begin(), vec.end());
    display(number);
    cout << "*it = " << *it << endl;
    cout << endl;

    it = number.begin();
    ++it;
    ++it;
    number.insert(it, {44, 444, 4444, 44444});
    display(number);
    cout << "*it = " << *it << endl;
    cout << endl;

    cout << "===== test_vector =====" << endl << endl;
}

int main(){
    test_deque();
    test_list();
    test_vector();
    return 0;
}

